package com.lepu.pcecg500;

import android.app.Application;
import com.CommonApp;
import com.lepu.pcecg500.util.CrashHandler;
import com.net.KoinInit;
import com.net.util.LogUtil;
import com.tencent.bugly.crashreport.CrashReport;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import rxhttp.RxHttp;
import rxhttp.wrapper.ssl.HttpsUtils;

/**
 * 说明: java
 * zrj 2022/3/24 15:18
 */
public class JavaApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        CommonApp.init(this);
//        CrashReport.initCrashReport(getApplicationContext(), "39b2b79695", false);
        KoinInit.INSTANCE.koinStart(this);
        LogUtil.INSTANCE.init(this);
        CrashHandler.getInstance().init(this);
        RxHttp.init(getDefaultOkHttpClient(), true);
    }

    private static OkHttpClient getDefaultOkHttpClient() {
        HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory();
        return new OkHttpClient.Builder()
                .connectTimeout(15, TimeUnit.SECONDS)
                .readTimeout(15, TimeUnit.SECONDS)
                .writeTimeout(15, TimeUnit.SECONDS)
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager) //添加信任证书
                .hostnameVerifier((hostname, session) -> true) //忽略host验证
                .build();
    }
}
